package com.imy.alscript;


import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

import com.imy.virtual.client.core.VirtualCore;

public class SplashActivity extends AppCompatActivity {
  private TextView mTextView;
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_splash);
    mTextView = (TextView) findViewById(R.id.splash_tv);
    Log.i("SplashActivity","isEngineLaunched:"+VirtualCore.get().isEngineLaunched());
    mTextView.postDelayed(new Runnable() {
      @Override
      public void run() {
        new Thread(new Runnable() {
          @Override
          public void run() {
            while (!VirtualCore.get().isEngineLaunched()){
              VirtualCore.get().waitForEngine();
            }
            jumpToMain();
          }
        }).start();
      }
    },100);

  }

  private void jumpToMain() {
    runOnUiThread(new Runnable() {
      @Override
      public void run() {
        mTextView.setText("server进程启动完毕。 即将启动主页");
        mTextView.postDelayed(new Runnable() {
          @Override
          public void run() {
            startActivity(new Intent(SplashActivity.this,MainActivity.class));
            finish();
          }
        },100);

      }
    });
  }
}